package com.xqit.ydzhkt.answer.service.impl;


import com.github.pagehelper.PageHelper;
import com.xqit.ydzhkt.answer.mapper.ListAnswerMapper;
import com.xqit.ydzhkt.answer.mapper.QueryQuestionTitleMapper;
import com.xqit.ydzhkt.answer.service.ListAnswerService;
import com.xqit.ydzhkt.entity.AnswerEntity;
import com.xqit.ydzhkt.entity.QuestionEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * Created by Janus on 2020/6/9
 */
@Service
public class ListAnswerServiceImpl implements ListAnswerService {
    @Autowired
    ListAnswerMapper listAnswerMapper;
    @Autowired
    QueryQuestionTitleMapper queryQuestionTitleMapper;

    @Override
    public QuestionEntity listAnswer(@RequestParam("id")int id,
    @RequestParam(defaultValue = "1",value = "pageNum") Integer pageNum,
     @RequestParam(defaultValue = "2",value = "pageSize") Integer pageSize) {
        QuestionEntity q = queryQuestionTitleMapper.queryQuestionContent(id);
        //把所有的教师回答查出来
        PageHelper.startPage(pageNum,pageSize);
        List<AnswerEntity> listAnswerEntity = listAnswerMapper.listAnswer(id);
        //把所有的学生回答查出来
      //  List<AnswerEntity> listsAnswerEntity = listAnswerMapper.listsAnswer(id);

        //把所有的学生回答 放到 教师回的集合里面
       // listAnswerEntity.addAll(listsAnswerEntity);
      //  listAnswerEntity.addAll(listsAnswerEntity);

        //ba 集合传给 回答
        q.setListAnswerEntity(listAnswerEntity);

    //    PageHelper.startPage(pageNum,pageSize);
        return q;

    }

}
